package com.qire.manhua.controller;

import android.view.View;

import com.qire.antsrouter.AntsRouter;
import com.qire.antsrouter.card.FloorCard;
import com.qire.common.constant.DeviceConfigInfo;
import com.qire.common.constant.Navigation;
import com.qire.common.constant.Url;
import com.qire.common.support.base.EventController;
import com.qire.common.utils.OSUtil;
import com.qire.manhua.activity.AccountActivity;
import com.qire.manhua.databinding.ActivityAccountBinding;
import com.qire.manhua.dialog.ObtainWaySelectorOfBeanDialog;
import com.qire.other.recorder.ComicActionRecorder;

import androidx.annotation.NonNull;

public class AccountController extends EventController<AccountActivity> {

    public AccountController(@NonNull AccountActivity lifecycleOwner) {
        super(lifecycleOwner);
    }

    @Override
    protected void bindView() {
        ActivityAccountBinding viewDataBinder = owner.viewDataBinder();
        viewDataBinder.setAccountController(this);
    }

    /**************************************************************************************************************/

    public void backBtnOnClick(View view) {
        owner.onBackPressed();
    }

    // 在线客服
    public void onlineServiceOnClick(View view) {
        OSUtil.launchQQ(owner, DeviceConfigInfo.qqNumber());
    }

    // 帮助中心
    public void helpCenterOnClick(View view) {
        AntsRouter.ROUTER.<FloorCard>buildCard(Navigation.Page.WebPage)
                .withData("title","帮助与反馈")
                .withData("url", Url.helpAndFeedback_url)
                .navigation();
    }

    // 金币记录
    public void coinRecordsBtnOnClick(View view) {
        AntsRouter.ROUTER.buildCard(Navigation.Page.AccountDetailCoinPage).navigation();
    }

    // 金币充值
    public void rechargeBtnOnClick(View view) {
        AntsRouter.ROUTER.buildCard(Navigation.Page.BuyCoinsMarketPage).navigation();
        // 行为数据统计
        ComicActionRecorder.build(ComicActionRecorder.count_recharge_show)
                .putParam("来源", "我的账户充值按钮")
                .doRecorde(view.getContext());
    }

    // 金豆记录
    public void beanRecordsBtnOnClick(View view) {
        AntsRouter.ROUTER.buildCard(Navigation.Page.AccountDetailBeanPage).navigation();
    }

    // 金豆获取方式及使用规则
    public void getBeanWayBtnOnClick(View view) {
//        AntsRouter.ROUTER.buildCard(Navigation.Page.BeanAcquireAndUseRulePage).navigation();
        new ObtainWaySelectorOfBeanDialog(view.getContext()).show();
    }

    // 消费记录
    public void purchasedBtnOnClick(View view) {
        AntsRouter.ROUTER.buildCard(Navigation.Page.AccountPurchaseHistoryPage).navigation();
    }

}
